<template>
    <div>
        <span @click="add('-')" v-show="num >0">-</span>
        <span>{{num}}</span>
        <span @click="add('+')">+</span>
    </div>
</template>

<script>
export default {
    props:["num","id"],
    methods:{
        add(btn,id){
            let num =  btn == "-" ? this.num-1 : this.num +1
            this.$bus.$emit("add",{num:num,id:this.id})
        }
    }
}
</script>

<style scoped>
div{
    padding-top:10px;
}
    span{
        border: 1px solid #ccc;
        padding: 2px 10px;;
    }
</style> 
